home *** CD-ROM | disk | FTP | other *** search
- /*
- * ConfigTranslator.c
- *
- * © 1993 by Apple Computer, Inc., all rights reserved.
- */
-
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Quickdraw.h>
- #include <TextEdit.h>
- #include <Types.h>
-
- #include "DialogUtilities.h"
- #include "ODBCSharedLibraries.h"
- #include "ConfigTranslator.h"
-
- #define ConfigTranslatorDlogID 132
-
- #define iOKButton 1
- #define iCancelButton 2
- #define iOption1 3
- #define iOption2 4
- #define iOption3 5
- #define iOption4 6
- #define iRect1 7
- #define iOptionsLabel 8
- #define iTitle 9
- #define iTitleUnderline 10
-
- typedef struct
- {
- GrafPtr savePort;
- DialogPtr dialog;
- DWORD *pvOption;
- }
- ConfigTranslatorRec;
-
- static ConfigTranslatorRec gConfigTranslatorRec;
-
- Boolean Initialize (WindowPtr parentWindow, DWORD *pvOption);
- void Cleanup ();
- void DoTranslationOption (short itemNr);
- Boolean DoOkButton ();
-
- Boolean
- DoConfigTranslator(WindowPtr parentWindow, DWORD *pvOption)
- {
- Boolean result;
- Boolean done = false;
- short itemNr;
-
- UPPInit( uppModalFilterProcInfo, StandardFilter )
-
- if (!Initialize(parentWindow, pvOption)) return false;
-
- while (!done)
- {
- ModalDialog( UPP(StandardFilter), &itemNr);
- switch (itemNr)
- {
- case iOKButton:
- done = result = DoOkButton();
- break;
-
- case iCancelButton:
- result = false;
- done = true;
- break;
-
- case iOption1:
- case iOption2:
- case iOption3:
- case iOption4:
- DoTranslationOption(itemNr);
- break;
- }
- }
-
- Cleanup();
-
- return result;
- }
-
- UPPInitStatic(uppUserItemProcInfo,DrawItemRect)
- UPPInitStatic(uppUserItemProcInfo,DrawItemDoubleLine)
-
- Boolean
- Initialize(WindowPtr parentWindow, DWORD *pvOption)
- {
- DialogPtr dialog;
- GrafPtr savePort;
- short btn;
-
- GetPort(&savePort);
- InitCursor();
- dialog = GetNewDialogOverWindow(ConfigTranslatorDlogID, parentWindow);
- if (dialog == NULL) goto bail;
- SetPort(dialog);
-
- SetDUserItem(dialog, iRect1, (UniversalProcPtr)UPP(DrawItemRect) );
- SetDUserItem(dialog, iTitleUnderline, (UniversalProcPtr)UPP(DrawItemDoubleLine) );
-
- gConfigTranslatorRec.savePort = savePort;
- gConfigTranslatorRec.dialog = dialog;
- gConfigTranslatorRec.pvOption = pvOption;
-
- btn = *pvOption + iOption1;
- if (btn < iOption1) btn = iOption1;
- if (btn > iOption4) btn = iOption4;
- SetDRadioButton(dialog, btn, iOption1, iOption4);
-
- ShowWindow(dialog);
-
- return true;
-
- bail:
-
- if (dialog != NULL) DisposDialog(dialog);
- SetPort(savePort);
-
- return false;
- }
-
- void
- Cleanup()
- {
- DisposDialog(gConfigTranslatorRec.dialog);
- SetPort(gConfigTranslatorRec.savePort);
- }
-
- Boolean
- DoOkButton()
- {
- short btn;
-
- btn = GetDRadioButton(gConfigTranslatorRec.dialog, iOption1, iOption4);
- *(gConfigTranslatorRec.pvOption) = btn - iOption1;
-
- return true;
- }
-
- void
- DoTranslationOption(short itemNr)
- {
- SetDRadioButton(gConfigTranslatorRec.dialog, itemNr, iOption1, iOption4);
- }
-